define([
  'backbone',
 '../other/cheeringMessage',
 '../other/pageTypeList',
  ////////////////gapi.client,
], function(Backbone, cheeringMessage, pageTypeList){
			var innerLayoutModel = Backbone.Model.extend({
				defaults: function() {
				  return {
					pageType: pageTypeList[0],
					text: "",
					albumId: '',
					photoId: '',
					searchStr: ''
				  };
				},
				initialize: function() {
					var th = this;
					var	goAlbumsList = function() {
						th.set({
						pageType: pageTypeList[0],
						albumId: ''
					  });
					};
					var goPhotosList = function(albumId) {
						th.set({
							pageType: pageTypeList[1],
							albumId: albumId,
							photoId: ''
						  });
					};
					var goToPhoto = function(photoId) {
						th.set({
							pageType: pageTypeList[2],
							photoId: photoId
						  })
					};					
					this.goForward = function(id) {
						if(this.get('pageType') == pageTypeList[0])
							goPhotosList(id);
						else if(this.get('pageType') == pageTypeList[1])
							goToPhoto(id);
					};
					this.goBack = function() {
						if(this.get('pageType') == pageTypeList[1])
							goAlbumsList();
						else if(this.get('pageType') == pageTypeList[2])
							goPhotosList(this.get('albumId'));
					};
					var model = this;
					(function() {
						var userName;
						gapi.client.load('plus', 'v1', function() {
							  var request = gapi.client.plus.people.get({
								'userId': 'me'
							  });
							  request.execute(function(resp) {
								if (resp && !resp.error) {
									cheeringMessage.set(cheeringMessage.get() + resp.name.givenName);
									if(model.get('pageType') == pageTypeList[0])
										model.setNewHeader(cheeringMessage.get());
								}
							  });
						});
					})();
				},
				setNewHeader: function(newText) {
					this.set({
						text: newText
					  })
				}
			});
		  return innerLayoutModel;
});